Fix pre-existing code quality bugs (#289)#312
Conversation
- Fix busy-wait CPU spike on shutdown in AppProcess.terminate() - Fix race condition on queue internals in ExtractDispatch - Fix user=None producing "None@host" in Sshcp with _remote_address helper - Fix wrong boolean operator in test_dispatch wait loop (and -> or) - Fix unclosed urlopen response in WebhookNotifier - Fix leaked Popen/fnull in integration test setup (use subprocess.run) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR addresses multiple pre-existing code quality issues identified during the Ruff linting review ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/python/ssh/sshcp.py`:
- Around line 42-46: Sshcp.copy() still builds a remote target with a direct
"{user}@{host}" format which can produce "None@host"; update the Sshcp.copy()
implementation to call the existing helper _remote_address() (the method defined
as def _remote_address(self) -> str) wherever the code constructs the remote
"user@host" string so the logic that returns just host when user is None is
reused and the None@host output is eliminated.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 66afc1e1-8ada-4d64-9e3c-a1d7b5fec68e
📒 Files selected for processing (8)
src/python/common/app_process.pysrc/python/controller/extract/dispatch.pysrc/python/controller/notifier.pysrc/python/ssh/sshcp.pysrc/python/tests/integration/test_controller/test_controller.pysrc/python/tests/integration/test_controller/test_extract/test_extract.pysrc/python/tests/unittests/test_controller/test_extract/test_dispatch.pysrc/python/tests/unittests/test_ssh/test_sshcp_remote_address.py
The copy() method still had a direct "{}@{}".format(user, host) that
would produce "None@host" when user is None.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Fixes 7 pre-existing code quality bugs identified during the Ruff review in #289:
AppProcess.terminate()had awhile self.is_alive(): passloop burning CPU. Addedtime.sleep(0.05)to yield the CPU.ExtractDispatchaccessedself.__task_queue.queue(the raw deque) without holding the queue mutex. Wrapped all accesses inwith self.__task_queue.mutex:.Sshcpformatted"{}@{}".format(self.__user, self.__host)unconditionally. Added_remote_address()helper that omits user when None.test_extract_ignores_duplicate_callsusedandinstead ofor, causing premature loop exit.WebhookNotifier._send_post()didn't close the response fromurlopen. Wrapped inwithstatement.setUpClassusedsubprocess.Popenwithout waiting for completion. Replaced withsubprocess.run(..., check=True)._create_archiveleaked anopen(os.devnull)handle. Replaced withsubprocess.run(..., stdout=subprocess.DEVNULL, check=True).Test plan
test_dispatch.pytests passSshcp._remote_address()(user set, user None, default)ruff formatandruff checkpass on all changed filesCloses #289
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Performance